﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WebSocket4Net;

namespace WpfAppWebSocket1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        WebSocketClient1 client = new WebSocketClient1();

        public MainWindow()
        {
            InitializeComponent();
            client.Received += Client_Received;
        }

        private void Client_Received(string message)
        {
            txtHistory.Text += message;
        }

        private async void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            //await client.Connect("ws://localhost:8081/websocket/1");
            await client.Connect("ws://localhost:8082/websocket/1");
            //await client.Connect("ws://localhost:8083/websocket1/1");
            //await client.Connect("ws://localhost:8084/websocket/1");

            //new WebSocketClient2().connectWebsocket();
        }

        private async void btnSendMessage_Click(object sender, RoutedEventArgs e)
        {
            await client.SendMessage("c#");

            //new WebSocketClient2().connectWebsocket();
        }
    }
}
